import { routerRedux } from 'dva/router';
import * as LoginService from '../services/basics';

var roles=[];

export default {
  namespace: 'bindPackage',
  state: {
    list: [],
    currentUser: {},
  },

  effects: {
		//查询列表
		*queryList({ payload ,callback}, { call, put }) {
				const response = yield call(LoginService.get,'/api/web/queryChildrenBindingPackageOthers',payload); 
		yield put({type: 'save',payload: response.data.obj});
		},
	/* 查询用户电话 */
	*queryPhoneList({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/user/getUserList',payload); 
		callback(response.data.res,response.data.obj);
	},
	/* 点击客户电话 查询孩子/已拥包 */
	*queryDataByPhone({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/queryChlidrenInformation',payload); 
		callback(response.data.res,response.data.obj);
	},
	/* 查询所有的课程包 */
	*queryPacakage({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/system/getAloneCoursePage',payload); 
		callback(response.data.res,response.data.obj);
	},
	/* 新增绑定包 */
	*insertBindPacakage({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/insertChildrenBindingPackage',payload); 
		callback(response.data.res,response.data.resMsg);
	},
	/* 查询所有的教室 */
	*queryClassroom({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/classroom/getClassroomList',payload);
		callback(response.data.res,response.data.obj);
	},
	/* 根据教室查绑定的课程包 */
	*queryPackageByClassroom({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/querySlfClassroomPackage',payload); 
		callback(response.data.res,response.data.obj);
	},
	/* 查询所有的孩子 */
	*queryChildren({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/queryChildrenBindingPackage',payload); 
		callback(response.data.res,response.data.obj);
	},
	/* 添加绑定 班级 */
	*insetClassForm({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/insertOrganizationClass',payload); 
		callback(response.data.res,response.data.resMsg);
	},
	/* 退出班级 */
	*deletClassForm({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/retire',payload); 
		callback(response.data.res,response.data.resMsg);
	},
	/* 插班 */
	*checkInClass({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/joinClass',payload); 
		callback(response.data.res,response.data.resMsg);
	},
	/* 插班:  根据所选小孩绑定的包筛选出班级 */
	*queryClassByPackageOfChild({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/queryOrganizationClass',payload); 
		callback(response.data.res,response.data.obj);
	},
	/* 编辑 */ 
	*updateForm({ payload,callback }, { call, put }) {
		const response = yield call(LoginService.get,'/api/web/updateChildrenBindingPackage',payload); 
		callback(response.data.res,response.data.resMsg);
	},
  },
  reducers: {
  	save(state, action) {
  		return {
  			...state,
  			data: action.payload,
  		};
  	},
  },
};






